package com.zhan.ielts.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.zhan.frame.core.dao.impl.BaseDaoImpl;
import com.zhan.frame.core.exception.DaoException;
import com.zhan.frame.core.utils.BeanUtils;
import com.zhan.ielts.dao.DynamicCodeDao;
import com.zhan.ielts.domain.DynamicCode;

@Repository
public class DynamicCodeDaoImpl extends BaseDaoImpl<DynamicCode> implements DynamicCodeDao {
	@Override
	public void updateMobileBatch(List<DynamicCode> list) {
		 sqlSessionTemplate.selectOne(getSqlName("updateMobileBatch"), list);
	}

	@Override
	public Long selectCountByCustom(DynamicCode query) {
		try {
			Map<String, Object> params = BeanUtils.toMap(query);
			return sqlSessionTemplate.selectOne(getSqlName("selectByCustom"), params);
		} catch (Exception e) {
			throw new DaoException(String.format("查询对象数量出错！语句：%s", getSqlName("selectByCustom")), e);
		}
	}

	@Override
	public void updateByCustom(DynamicCode dynamicCode) {
		try {
			Map<String, Object> params = BeanUtils.toMap(dynamicCode);
			sqlSessionTemplate.update(getSqlName("updateByCustom"), params);
		} catch (Exception e) {
			throw new DaoException(String.format("查询对象数量出错！语句：%s", getSqlName("selectByCustom")), e);
		}
	}

	@Override
	public Long selectCountMin(DynamicCode query) {
		try {
			Map<String, Object> params = BeanUtils.toMap(query);
			return sqlSessionTemplate.selectOne(getSqlName("selectCountMin"), params);
		} catch (Exception e) {
			throw new DaoException(String.format("查询对象数量出错！语句：%s", getSqlName("selectCountMin")), e);
		}
	}
	
}
